from math import pow

n = int(input())
sum_n = 0

for _ in range(n):
    bi = input()
    ge = bi[-1]
    base = bi[:-1]
    sum_n += pow(*tuple(map(int, (base, ge))))

print(int(sum_n))
